package com.leecode;

public class Hebingyouxushuzu {
    public static void main(String[] args) {
        int[] nums1 = new int[]{1,2,3,0,0,0};
        int m = 3;
        int n = 3;
        int[] nums2 = new int[]{2,5,6};
        merge(nums1,m,nums2,n);
    }

    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        for(int i=n-1;i>=0;){
            if(m>0 & nums2[i]<=nums1[m-1]){
                System.out.print(m);
                nums1[m+i] = nums1[m-1];
//                nums1[m-1] = 0;
                m--;
            }else{
                nums1[m+i] = nums2[i];
                i--;
            }
        }
        System.out.print(nums1);
    }
}
